

import java.awt.*;
import java.awt.event.KeyEvent;
import javax.swing.*;
import javax.swing.text.Keymap;

public class Contra extends javax.swing.JFrame {
imagencontra ic = new imagencontra();
    /** Creates new form Contra */
    public Contra() {
        initComponents();

 /*Image icon = Toolkit.getDefaultToolkit().getImage(getClass().getResource("/Imagenes/icono2.png"));
        setIconImage(icon);*/
this.add(ic,BorderLayout.CENTER);
this.pack();
this.setTitle("Software Control de Clientes");
this.setResizable(false);
   this.setLocation(480,150);
    this.setSize(325,325);jTextField1.setText("Admin");
   jTextField1.setToolTipText("Inserte Usuario");
    jPasswordField1.setToolTipText("Inserte Contraseña");}
/*
public Icon getIcon3(){
return new ImageIcon(getClass().getResource("/Imagenes/salirv.png"));}
public Icon getIcon4(){
return new ImageIcon(getClass().getResource("/Imagenes/blockdevice.png"));}
public Icon getIcon5(){
return new ImageIcon(getClass().getResource("/Imagenes/Globe2.png"));}*/
    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jButton1 = new javax.swing.JButton();
        jTextField1 = new javax.swing.JTextField();
        jPasswordField1 = new javax.swing.JPasswordField();
        jLabel1 = new javax.swing.JLabel();
        jLabel2 = new javax.swing.JLabel();
        BarradeMenus = new javax.swing.JMenuBar();
        Archivo = new javax.swing.JMenu();
        jSeparator2 = new javax.swing.JPopupMenu.Separator();
        jMenuItem2 = new javax.swing.JMenuItem();
        jMenuItem1 = new javax.swing.JMenuItem();

        setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
        setResizable(false);

        jButton1.setText("Iniciar");
        jButton1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton1ActionPerformed(evt);
            }
        });

        jTextField1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jTextField1ActionPerformed(evt);
            }
        });

        jPasswordField1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jPasswordField1ActionPerformed(evt);
            }
        });

        jLabel1.setForeground(new java.awt.Color(255, 255, 255));
        jLabel1.setText("Usuario");

        jLabel2.setForeground(new java.awt.Color(255, 255, 255));
        jLabel2.setText("Contraseña");

        Archivo.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Imagenes/fileopen.png"))); // NOI18N
        Archivo.setText("Archivo");
        Archivo.add(jSeparator2);

        jMenuItem2.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Imagenes/back.png"))); // NOI18N
        jMenuItem2.setText("Inicio");
        jMenuItem2.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItem2ActionPerformed(evt);
            }
        });
        Archivo.add(jMenuItem2);

        jMenuItem1.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Imagenes/edit_user.png"))); // NOI18N
        jMenuItem1.setText("Entrar Como Cliente");
        jMenuItem1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItem1ActionPerformed(evt);
            }
        });
        Archivo.add(jMenuItem1);

        BarradeMenus.add(Archivo);

        setJMenuBar(BarradeMenus);

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGap(35, 35, 35)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(jLabel2)
                    .addComponent(jLabel1))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
                    .addComponent(jTextField1, javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jPasswordField1, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.PREFERRED_SIZE, 119, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap(84, Short.MAX_VALUE))
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                .addContainerGap(124, Short.MAX_VALUE)
                .addComponent(jButton1)
                .addGap(113, 113, 113))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                .addContainerGap(204, Short.MAX_VALUE)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jTextField1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel1))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jPasswordField1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel2))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jButton1)
                .addContainerGap())
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed

if(String.valueOf(jTextField1.getText()).compareTo("Admin")==0&&String.valueOf(jPasswordField1.getPassword()).compareTo("1234")==0){
dispose();Principal h= new Principal(); h.setVisible(true);Home p = new Home(); p.setVisible(false);
}else
JOptionPane.showMessageDialog(null, "Usuario﻿ o Contraseña Incorrecta","ERROR",JOptionPane.WARNING_MESSAGE);
jPasswordField1.setText("");
    }//GEN-LAST:event_jButton1ActionPerformed

    private void jPasswordField1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jPasswordField1ActionPerformed
if(evt.getSource()==jPasswordField1&&String.valueOf(jTextField1.getText()).compareTo("Admin")==0&&String.valueOf(jPasswordField1.getPassword()).compareTo("1234")==0){
  dispose();Principal h= new Principal(); h.setVisible(true);
}
 else
     JOptionPane.showMessageDialog(null, "Usuario﻿ o Contraseña Incorrecta","ERROR",JOptionPane.WARNING_MESSAGE);
jPasswordField1.setText("");
    }//GEN-LAST:event_jPasswordField1ActionPerformed

    private void jTextField1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jTextField1ActionPerformed
if(evt.getSource()==jTextField1&&String.valueOf(jTextField1.getText()).compareTo("Admin")==0&&String.valueOf(jPasswordField1.getPassword()).compareTo("1234")==0){
  dispose();Principal h= new Principal(); h.setVisible(true);
}
 else
     JOptionPane.showMessageDialog(null, "Usuario﻿ o Contraseña Incorrecta","ERROR",JOptionPane.WARNING_MESSAGE);
jPasswordField1.setText("");

    }//GEN-LAST:event_jTextField1ActionPerformed

    private void jMenuItem2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem2ActionPerformed
Home h = new Home();h.setVisible(true);
dispose();
    }//GEN-LAST:event_jMenuItem2ActionPerformed

    private void jMenuItem1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem1ActionPerformed
cliente c = new cliente();
c.setVisible(true);dispose();
    }//GEN-LAST:event_jMenuItem1ActionPerformed
public static void main (String []args){
 new Contra().setVisible(true);
}
    

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JMenu Archivo;
    private javax.swing.JMenuBar BarradeMenus;
    private javax.swing.JButton jButton1;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JMenuItem jMenuItem1;
    private javax.swing.JMenuItem jMenuItem2;
    private javax.swing.JPasswordField jPasswordField1;
    private javax.swing.JPopupMenu.Separator jSeparator2;
    private javax.swing.JTextField jTextField1;
    // End of variables declaration//GEN-END:variables

}
